package com.ssy.lingxi.member.merchant.repository;

import com.ssy.lingxi.member.merchant.entity.MemberDO;
import com.ssy.lingxi.member.merchant.entity.MemberOrganizationDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 会员自定义组织机构操作类
 * @author 万宁
 * @version 2.0.0
 * @date 2020-06-28
 */
@Repository
public interface MemberOrganizationRepository extends JpaRepository<MemberOrganizationDO, Long>, JpaSpecificationExecutor<MemberOrganizationDO> {
    boolean existsByMemberAndTitle(MemberDO memberDO, String title);

    List<MemberOrganizationDO> findByMemberAndKeyStartsWith(MemberDO memberDO, String key);

    List<MemberOrganizationDO> findByMember(MemberDO member);

    void deleteByMemberIdAndStoreId(Long memberId, Long storeId);

    MemberOrganizationDO findFirstByMemberIdAndStoreId(Long memberId, Long storeId);

    List<MemberOrganizationDO> findByMemberId(Long memberId);
}
